package com.cdsxt.base;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

/**
 * 
 * @author 成都尚学堂 & mr zeng
 * 客服热线：028-65176856
 * 网址： www.cd-sxt.com
 * 
 * 
 * a）定义了BaseEntity类 让子类实体继承（id，createDate，updateDate）子类可以直接使用
 * 但是注意：hibernate默认没有扫描：对应属性的注解（@Id@GeneratedValue@Column）所有这些属性没有和表映射！！！
 * 
 * b）如果希望hibernate扫描对应的注解：在父类配置@MappedSuperclass
 */
@MappedSuperclass
public class BaseEntity implements Serializable{
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	//主键
	private Integer id;
	
	//创建时间
	@Column(name="create_date")
	private Date createDate;
	
	//更新时间
	@Column(name="update_date")
	private Date updateDate;
	
	public BaseEntity() {
		// TODO Auto-generated constructor stub
	}

	
	
	public BaseEntity(Integer id) {
		super();
		this.id = id;
	}



	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	@Override
	public String toString() {
		return "BaseEntity [id=" + id + ", createDate=" + createDate
				+ ", updateDate=" + updateDate + "]";
	}
	
	
	
}
